<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
</head>
<body>
    <div id="应用">
        <!-- <警告框></警告框> -->
    </div>
</body>
<script>
    const 应用 = Vue.createApp({
        template: `
            <my 标题='按钮1' @点击="函数($event)"></my>
            <my 标题='按钮2' @点击="函数($event)"></my>
        `,
        methods: {
            函数(标题) {
                console.log(`点击了自定义组件 ${标题}`)
            }
        }
    })
    const 组件 = {
        data() {
            return {
                消息: '警告框显示',
                计数: 0,
            }
        },
        methods: {
            点击() {
                alert(this.消息 + ' ' + this.计数++)
            }
        },
        props: ['标题'],
        template: `<div><button @click="$emit('点击', 标题)">{{标题}}</button></div>`,
    }
    应用.component('my', 组件)
    应用.mount('#应用')
</script>
</html>